import QtQuick 2.9
import QtQuick.Controls 2.5

Rectangle {
    id: root
    color: "#99333333"

    signal clickedYes()
    signal clickedNo()

    function show(title, message) {
        root.visible = true
        txtTitle.text = title
        txtTitle.visible = title.length > 0

        txtText.text = message
        txtText.height = title.length > 0 ?
                    layoutContent.height * 0.6 :
                    layoutContent.height * 0.8

    }

    ///////////////////////////////////////////////

    MouseArea {
        anchors.fill: parent
//        acceptedButtons: Qt.AllButtons
//        hoverEnabled: true
        onClicked: {}
        onPressed: {}
        onReleased: {}
    }

    Rectangle {
        id: layoutContent
        width: root.width * 0.6
        height: root.height * 0.4
        anchors.centerIn: parent

        color: "#f1f1f1"
        radius: 10

        Column {
            width: parent.width
            height: parent.height
            Text {
                id: txtTitle
                width: parent.width
                height: layoutContent.height * 0.2
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: height * 0.5
                text: qsTr("速析能 HPY")
            }
            Rectangle {
                width: parent.width; height: 1
                color: "#999"
            }
            Text {
                id: txtText
                width: parent.width
                height: layoutContent.height * 0.6
                font.pixelSize: txtTitle.height * 0.3
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                leftPadding: width * 0.05
                rightPadding: width * 0.05
                wrapMode: Text.Wrap
                elide: Text.ElideRight
                text: qsTr("")
            }
            Rectangle {
                width: parent.width; height: 1
                color: "#999"
            }

            //...底部按钮
            Row {
                width: parent.width
                height: layoutContent.height * 0.2

                FlatButton {
                    width: parent.width * 0.5
                    height: parent.height
                    text: qsTr("否")
                    textColor: "#2E75B6"
                    backgroundColor: "transparent"
                    onClicked: {
                        root.visible = false
                        clickedNo()
                    }
                }

                Rectangle {
                    width: 1
                    height: parent.height
                    color: "#666"
                }

                FlatButton {
                    width: parent.width * 0.5
                    height: parent.height
                    text: qsTr("是")
                    textColor: "#2E75B6"
                    backgroundColor: "transparent"
                    onClicked: {
                        root.visible = false
                        clickedYes()
                    }
                }

            }//...底部按钮
        }
    }
}
